from rest_framework import serializers
from . import models



# 产品序列化
class Gooserializer(serializers.ModelSerializer):

    class Meta:
        model = models.Goods
        fields = '__all__'



# 订单序列化
class Orderserializer(serializers.ModelSerializer):

    class Meta:
        model = models.Order
        fields = '__all__'

class Orderserializer1(serializers.ModelSerializer):
    goods = serializers.SerializerMethodField()
    class Meta:
        model = models.Order
        fields = ('goods',)

    def get_goods(self,obj):
        data = Gooserializer(obj.goods)
        return data.data